/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.saar.penguin.give2.server.alert;

import de.saar.penguin.give2.server.BigBrother;
import de.saar.penguin.give2.server.Instruction;
import de.saar.penguin.give2.server.SaarNlgSystem;

/**
 *
 * @author koller
 */
public class ApproachingObjectAlert extends Alert {
    private String targetName;
    private String message;

    public ApproachingObjectAlert(SaarNlgSystem nlg, String targetName, String message) {
        super(nlg);
        this.targetName = targetName;
        this.message = message;
    }
    

    @Override
    public boolean isActivated(BigBrother bb) {
        return w().getPlayerPosition().distance(w().getPosition(targetName)) < 0.75;
    }

    @Override
    public Instruction getInstruction() {
        return new Instruction(message);
    }

    @Override
    public boolean isFinished() {
        return !getCurrentRoom().equals(roomWeGotInitialized);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ApproachingObjectAlert other = (ApproachingObjectAlert) obj;
        if ((this.targetName == null) ? (other.targetName != null) : !this.targetName.equals(other.targetName)) {
            return false;
        }
        if ((this.message == null) ? (other.message != null) : !this.message.equals(other.message)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 83 * hash + (this.targetName != null ? this.targetName.hashCode() : 0);
        hash = 83 * hash + (this.message != null ? this.message.hashCode() : 0);
        return hash;
    }


}
